package org.shiwen.week9.thurday.q4;

public class Test {
    public static void main(String[] args) {
        Developer developer = new Developer("张三",28);
        //创建一个数组长度为3，数组的数据类型为Vehicle
        Vehicle vehicle[] = new Vehicle[3];
        //给数组内的每一个元素赋值
        vehicle[0] = new Bicycle("捷安特","红");
        vehicle[1] = new Car("白色","黑色","粤A12345");
        vehicle[2] = new ElectricVehicle("雅迪","白");

        //将数组内的对象通过循环的方式传递给开发人员，让他去调用takingVehicle方法
        for (int i = 0; i < vehicle.length; i++) {
            //让developer对象去调用takingVehicle方法
            //这个方法需要一个Vehicle类型的对象
            //通过循环让数组内的对象传递进方法里
            developer.takingVehicle(vehicle[i]);

            // 用instanceof 来判断这个对象有没有实现IPower接口，如果实现则调用power方法
            if(vehicle[i] instanceof IPower){
                ((IPower) vehicle[i]).power();
            }
        }
    }
}
